<?php
if ($_POST) {
 $js = $_POST['code'];
 $js = str_replace("\'", "'", $js);
} else {
 $js = '';
}
?>
<form method="post">
	<textarea rows=20 cols=60 name="code"><?php echo $js; ?></textarea>
	<input type="submit">
</form>
<?php

if ($_POST) {
 $php = str_replace('document.write(', 'echo ', $js);
 $php = str_replace(')', '', $php);
 echo '<br><br><pre>php:' . "\n" . $php; 
}
?>
